package day240530.baidu;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

public class BaiDu {
    public static void main(String[] args) throws IOException {
        URL url=new URL("https://www.baidu.com");
        URL url1=new URL("https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png");
        InputStream inputStream = url.openStream();
        InputStream inputStream1 = url1.openStream();
        FileOutputStream fileOutputStream = new FileOutputStream("src/day240530/baidu.txt");
        FileOutputStream fileOutputStream1=new FileOutputStream("src/day240530/baidu.png");
            int c;
            while ((c = inputStream.read()) != -1) {
                fileOutputStream.write(c);
            }{if (inputStream!=null){
                inputStream.close();
        }if (fileOutputStream!=null){
                fileOutputStream.close();
            }
        }
    }
}

